package com.houtai.eduservice.controller;


import com.houtai.commonutils.Result;
import com.houtai.eduservice.config.OperationLogDesc;
import com.houtai.eduservice.entity.subject.One;
import com.houtai.eduservice.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author lin
 * @since 2022-11-19
 */
@Api(description = "课程分类管理")
@RestController
@RequestMapping("/eduservice/subject")
//@CrossOrigin
public class EduSubjectController {
    @Autowired
    private EduSubjectService subjectService;
    //添加课程分类信息
    //获取上传过来文件，把文件内容读取出来
    @ApiOperation(value = "添加课程分类")
    @OperationLogDesc(module = "课程分类模块",description = "添加课程分类")
    @PostMapping("addSubject")
    public Result addSubject(MultipartFile file) {
        //上传过来excel文件
        subjectService.saveSubject(file,subjectService);
        return Result.ok();
    }

    //课程分类的列表（树形结构）
    @GetMapping("getAll")
    @ApiOperation(value = "课程分类列表")
    @OperationLogDesc(module = "课程分类模块",description = "查看课程分类")
    public Result getAll(){
        List<One> list=subjectService.getAllSubject();
        return Result.ok().data("list",list);
    }


}

